package com.eric.enderslastgame;

import java.util.ArrayList;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.FontMetrics;
import android.graphics.Paint.Style;
import android.renderscript.Font;
import android.util.Log;

//TODO Factor in the appearance of images being determined by its top left corner 
//(Human ship first appearing and Buggers showing off screen)
//TODO Trim rectangle hit boxes (people hate dying when only slight touch w/ Bugger)
//TODO Display time in paint method

// Note: "Screen" refers to a number that is assigned to each Bugger set and Human
// So the focused screen does not have a fixed screen number

public class Board {

	private static final String TAG = Board.class.getSimpleName();

	private Human human;
	private ArrayList<Bugger> buggers;

	private Paint textPaint;

	static boolean accelerating; // True indicates the player is accelerating
									// forward (Buggers move faster towards you)

	public Board(Human human, ArrayList<Bugger> buggers) {
		this.human = human;
		this.buggers = buggers;

		textPaint = new Paint();
		textPaint.setColor(Color.WHITE);
		textPaint.setStyle(Style.FILL);
	}

	public void setHuman(Human human) {
		this.human = human;
	}

	public void setBuggers(ArrayList<Bugger> buggers) {
		this.buggers = buggers;
	}

	public Human getHuman() {
		return human;
	}

	public ArrayList<Bugger> getBuggers() {
		return buggers;
	}

	public void draw(Canvas canvas) {
		if (EndersGamePanel.inGame) {

			for (int i = 0; i < buggers.size(); i++) {
				// Log.d(TAG, "Y Coordinate of current Bugger is " + i.getY());
				Bugger bugger = buggers.get(i);
				if (bugger != null) {
//					Log.d(TAG, "Y Coordinate of current Bugger is " + bugger.getY());
					canvas.drawBitmap(bugger.getBitmap(), bugger.getX(), bugger.getY(), null);
				}
			}

			canvas.drawBitmap(human.getBitmap(), human.getX(), human.getY(),
					null);

			canvas.drawText("Enemies Dodged: " + EndersGamePanel.dodgedCounter,
					5, 15, textPaint);
		} else {
			// TODO Add in message telling to press enter to restart
			canvas.drawText("Game Over", canvas.getWidth() / 2,
					canvas.getHeight() / 2, textPaint);
		}

	}
}
